<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import {ref, reactive} from 'vue'
import place from '@/api/logistics/place'
import {Message} from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'
import dictHelp from "@/utils/dicthelp.js";
const crudRef = ref()


const options = reactive({
  id: 'place',
  pageLayout: 'fixed',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'modal',
    width: '60%'
  },
  tabs: {
    dataIndex: "type",
    searchKey: "type",
  },
  api: place.getList,
  recycleApi: place.getRecycleList,
  add: {
    show: true,
    api: place.save,
    auth: ['logistics:place:save']
  },
  edit: {
    show: true,
    api: place.update,
    auth: ['logistics:place:update']
  },
  delete: {
    show: true,
    api: place.deletes,
    auth: ['logistics:place:delete'],
    realApi: place.realDeletes,
    realAuth: ['logistics:place:realDeletes']
  },
  recovery: {
    show: true,
    api: place.recoverys,
    auth: ['logistics:place:recovery']
  }
})

const columns = reactive([
  {
    title: "主键",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入主键"
    }
  },
  {
    title: "地点名称",
    dataIndex: "name",
    formType: "input",
    search: true,
    commonRules: {
      required: true,
      message: "请输入地点名称"
    }
  },
  {
    title: "地点名称(英)",
    dataIndex: "en",
    formType: "input",
    commonRules: {
      message: "请输入地点名称(英)"
    }
  },
  {
    title: "地点类型",
    dataIndex: "type",
    formType: "radio",
    type: 'button',
    search: true,
    commonRules: {
      required: true,
      message: "请输入地点类型"
    },
    dict: {
      name: "flrstLegType",
      translation: true
    }
  },
  {
    title: "货站",
    dataIndex: "depot_id",
    formType: "select",
    search: true,
    dict: dictHelp.depot
  },
  {
    title: "国家",
    dataIndex: "country",
    formType: "select",
    dict: {
      name: "countrys",
      props: {
        label: "title",
        value: "key"
      },
      translation: true
    }
  },
  {
    title: "州/省",
    dataIndex: "state",
    formType: "input"
  },
  {
    title: "城市",
    dataIndex: "city",
    formType: "input"
  },
  {
    title: "邮编",
    dataIndex: "postcode",
    formType: "input"
  },
  {
    title: "地址",
    dataIndex: "address_1",
    formType: "input"
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "备注",
    dataIndex: "remark",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default {name: 'logistics:place'} </script>